package com.cat.facade;

/**
 * @author cat
 * @version 2025/5/22 16:51
 * @description 智能家具
 * @since JDK17
 */

public class SmartAppliancesFacade {
    private Light light;
    private TV tv;
    private AirCondition airCondition;

    public SmartAppliancesFacade() {
        light = new Light();
        tv = new TV();
        airCondition = new AirCondition();
    }

    public void say(String msg) {
        if (msg.contains("打开")) {
            on();
        } else if (msg.contains("关闭")) {
            off();
        } else {
            System.out.println("不支持");
        }
    }

    // 一键打开操作
    public void on() {
        light.on();
        tv.on();
        airCondition.on();
    }

    // 一键关闭操作
    public void off() {
        light.off();
        tv.off();
        airCondition.off();
    }
}
